<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    
    <script>
        /* var jsonobj = {username:"admin",password:"123456"};
        var jsonStr = '{username:"admin",password:"123456"}'; */
        var jsonObj = {username:"admin",password:"123456"};
        //将json对象或json数组转换为json格式的字符串
        var jsonStr = JSON.stringify(jsonObj);
        //将json格式的字符串转换为json对象或json数组
        jsonObj = JSON.parse(jsonStr);
        console.log(jsonObj);
        console.log(jsonStr);
    </script>
</body>
</html>